<!--
 * @FileDescription 点云呈现
 * @Author 杨宇翔
 * @Date 20220714 10:39:37
 * @LastEditors 杨宇翔
 * @LastEditTime 20220714 10:39:37
-->
<template>
    <div class="scan" v-show="UseComponent.Default.Choice.value == '地图构建'">
        <i></i>
        <button class="reset" type="button" @click="OnChanged">
            <img
                :src="state ? `/static/LaserRadar/ic_zhankai.png` : `/static/LaserRadar/ic_shouqi.png`">
            <span>地图构建</span>
        </button>
        <span>
            {{ (duration / 3600 | 0).toString().padStart(2, '0') }}
            :
            {{ (duration % 3600 / 60 | 0).toString().padStart(2, '0') }}
            :
            {{ (duration % 3600 % 60).toString().padStart(2, '0') }}
        </span>
        <span>录制时间</span>
        <div class="button-container">
            <button class="reset" type="button" @click="UseComponent.Default.StartBuildMapAsync()">
                <img src="/static/LaserRadar/ic_play.png">
                <span>录制</span>
            </button>
            <button class="reset" type="button" @click="UseComponent.Default.StopBuildMapAsync()">
                <img src="/static/LaserRadar/ic_stop.png">
                <span>停止</span>
            </button>
        </div>
        <i></i>

        <input type="checkbox" hidden name="地图构建" id="scene" value="scene"
            v-model="UseComponent.Default.ShowScene.value">
        <label for="scene">
            <img src="/static/LaserRadar/ic_checkbox_normal.png">
            <span>显示场景</span>
        </label>

        <input type="checkbox" hidden name="地图构建" id="path" value="path" v-model="UseComponent.Default.ShowPath.value">
        <label for="path">
            <img src="/static/LaserRadar/ic_checkbox_normal.png">
            <span>显示采集路径</span>
        </label>

        <input type="checkbox" hidden name="地图构建" id="map" value="map" v-model="UseComponent.Default.ShowMap.value">
        <label for="map">
            <img src="/static/LaserRadar/ic_checkbox_normal.png">
            <span>显示三维地图</span>
        </label>

        <button class="reset" type="button">
            <span>重置</span>
        </button>

        <span>操作说明</span>

        <button class="reset key" type="button">
            <span>W</span>
            <span>前进</span>
        </button>

        <div class="key-container">
            <button class="reset key" type="button">
                <span>A</span>
                <span>左转</span>
            </button>
            <button class="reset key" type="button">
                <span>S</span>
                <span>后退</span>
            </button>
            <button class="reset key" type="button">
                <span>D</span>
                <span>右转</span>
            </button>
        </div>
    </div>
</template>

<script setup lang="ts">
import { UseComponent } from './LaserRadarComponent';
import { Ref, ref } from 'vue';

const duration: Ref<number> = ref(0);

const state = ref(true);

const sidebarTranslateX = ref('translateX(0)');
const buttonTranslateX = ref('translateX(0)');

function OnChanged() {
    state.value = !state.value;
    sidebarTranslateX.value = state.value ? 'translateX(0)' : 'translateX(100%)';
    buttonTranslateX.value = state.value ? 'translateX(0)' : 'translateX(-6rem)';
}
</script>

<style scoped>
.scan {
    position: absolute;
    top: 8rem;
    right: 0;

    width: 27rem;

    padding-bottom: 2rem;

    border-radius: 2rem 0 0 2rem;
    background-color: #131620;

    display: flex;
    flex-direction: column;
    align-items: flex-start;

    transform: v-bind(sidebarTranslateX);

    transition: transform 300ms;
}

.scan>span:nth-of-type(1),
.scan>span:nth-of-type(2) {
    display: inline-block;
    width: calc(100% - 0.6rem);
    height: 2rem;

    margin-left: 0.6rem;

    text-align: center;
    line-height: 2rem;
}

.scan>span:nth-of-type(1) {
    font-weight: 600;
}

.scan>span:nth-of-type(1) {
    color: #A2A2FF;
    font-size: 1.6rem;

    margin-top: 2rem;
    margin-bottom: 0.5rem;
}

.scan>span:nth-of-type(2) {
    color: #81859C;
    font-size: 1.4rem;

    margin-bottom: 2rem;
}

i:first-of-type {
    position: absolute;
    left: 0;
    bottom: 0;

    display: block;
    width: 100%;
    height: calc(100% - 5rem);

    border-left: solid 0.6rem transparent;
    border-bottom: solid 0.6rem transparent;
    border-radius: 0 0 0 2rem;
    background-image: linear-gradient(#131620, #131620),
        linear-gradient(90deg, #218cde, #807de1);
    background-origin: border-box;
    background-clip: content-box, border-box;

    z-index: -1;
}

i:last-of-type {
    align-self: center;

    width: 23rem;
    height: 0.1rem;
    background-color: #1F1F2D;

    margin-bottom: 2rem;
}

.scan>button:first-of-type {
    width: 100%;
    height: 5rem;

    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 1.4rem;

    padding-left: 2.4rem;

    background-color: #131620;

    border-radius: 2.5rem 0 0 2.5rem;
    box-shadow: inset 0 -0.1rem 0 0 #1F1F2D;

    transform: v-bind(buttonTranslateX);

    transition: transform 300ms;
}

.scan>button:first-of-type>span:first-of-type {
    color: #B1B1D4;
    font-size: 1.8rem;
    font-weight: 500;
}

.scan>button:nth-of-type(2) {
    align-self: center;

    width: 23rem;
    height: 3.4rem;

    border-radius: 0.6rem;
    background-color: #36384B;

    margin-bottom: 3rem;
}

.scan>button:nth-of-type(2)>span {
    color: white;
    font-size: 1.6rem;
}

.scan>span:nth-of-type(3) {
    display: inline-block;
    width: calc(100% - 0.6rem);
    height: 5rem;

    margin-left: 0.6rem;
    margin-bottom: 2rem;

    box-shadow: inset 0 -0.1rem 0 0 #1F1F2D;

    color: #B1B1D4;
    font-size: 1.8rem;
    text-indent: 2rem;
    line-height: 5rem;
}

.scan>label {
    padding-left: 2rem;

    display: flex;
    align-items: center;
    gap: 1rem;

    margin-bottom: 2rem;
}

.scan>label>span {
    color: #81859C;
    font-size: 1.6rem;
}

.scan>input:checked+label>span {
    color: white;
}

.scan>input:checked+label>img {
    content: url('/static/LaserRadar/ic_checkbox_select.png');
}

.button-container {
    align-self: center;

    display: flex;
    justify-content: center;
    align-items: center;
    gap: 7rem;

    margin-bottom: 2rem;
}

.button-container>button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.button-container>button>span {
    color: #81859C;
    font-size: 1.6rem;
}

.key {
    width: 6rem;
    height: 5rem;

    border-radius: 0.6rem;
    background-color: #36384B;

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.key>span:first-of-type {
    color: white;
    font-size: 1.4rem;
}

.key>span:last-of-type {
    color: #B1B1D4;
    font-size: 1.4rem;
}

.scan>.key {
    align-self: center;
}

.key-container {
    align-self: center;

    margin-top: 1rem;

    display: flex;
    align-items: center;
    gap: 1rem;
}
</style>